import 'package:flutter/material.dart';
import 'package:flutter_widget/custom/custom_appbar.dart';
import 'package:flutter_widget/utils/Plugin.dart';

class FlutterPluginPage extends StatefulWidget {
  const FlutterPluginPage({Key? key, required this.name}) : super(key: key);
  final String name;
  @override
  _FlutterPluginPageState createState() => _FlutterPluginPageState();
}

class _FlutterPluginPageState extends State<FlutterPluginPage> {
  // ignore: non_constant_identifier_names
  final List PluginLists = PluginUtils.PluginLists;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppbar(widget.name, Theme.of(context).primaryColor),
      body: Column(
        children: [
          Expanded(
            child: ListView(
              children: PluginLists.map(
                (e) {
                  final int index = PluginLists.indexOf(e) + 1;
                  return ListTile(
                    leading: CircleAvatar(
                      backgroundColor: Theme.of(context).primaryColor,
                      child: Text(index.toString()),
                      foregroundColor: Colors.white,
                    ),
                    title: Text(e['text']),
                    onTap: () {
                      Navigator.of(context).push(
                        MaterialPageRoute(
                          builder: (context) {
                            return e['content']; //返回的是需要跳转单页面
                          },
                        ),
                      );
                    },
                  );
                },
              ).toList(),
            ),
          ),
        ],
        mainAxisAlignment: MainAxisAlignment.center,
      ),
    );
  }
}
